package com.steadyoung.modelapp.fragment;

import android.app.Dialog;
import android.view.View;
import android.view.Window;

import com.steadyoung.alexdialog.annotation.ClickPosition;
import com.steadyoung.alexdialog.callback.OnDialogClickListener;
import com.steadyoung.modelapp.R;
import com.steadyoung.modelapp.base.BaseFragment;
import com.steadyoung.modelapp.widget.dialog.BottomDialog;
import com.steadyoung.modelapp.widget.dialog.LoadingDialog;
import com.steadyoung.modelapp.widget.dialog.NoticeDialog;
import com.steadyoung.modelapp.widget.dialog.OneButtonDialog;
import com.steadyoung.modelapp.widget.dialog.SelectedProductDialog;
import com.steadyoung.modelapp.widget.dialog.TwoButtonDialog;

import butterknife.OnClick;

/**
 * Created by Administrator on 2017/12/4.
 * Email : steadyoung@foxmail.com
 * Auth  : wayne
 * Desc  : TODO
 */

public class DialogFragment extends BaseFragment {

    BottomDialog bottomDialog;
    LoadingDialog loadingDialog;
    NoticeDialog noticeDialog;
    OneButtonDialog oneButtonDialog;
    SelectedProductDialog selectedProductDialog;
    TwoButtonDialog twoButtonDialog;

    @Override
    protected int getLayoutResId() {
        return R.layout.fm_dialog;
    }

    @Override
    protected void initData() {
    }

    @Override
    protected void initEvent() {

    }

    @OnClick({R.id.loading_dialog, R.id.bottom_dialog, R.id.one_button_dialog, R.id.two_button_dialog, R.id.notice_dialog, R.id.select_product_dialog})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.loading_dialog:
                if(loadingDialog == null){
                    loadingDialog = new LoadingDialog(mContext);
                }
                loadingDialog.show();
                break;
            case R.id.bottom_dialog:
                if(bottomDialog == null){
                    bottomDialog = new BottomDialog(mContext).setOnDialogClickListener(dialogClickListener);
                }
                bottomDialog.show();
                break;
            case R.id.one_button_dialog:
                if(oneButtonDialog == null){
                    oneButtonDialog = new OneButtonDialog(mContext).setOnDialogClickListener(dialogClickListener);
                }
                oneButtonDialog.show();
                break;
            case R.id.two_button_dialog:
                if(twoButtonDialog == null){
                    twoButtonDialog = new TwoButtonDialog(mContext).setOnDialogClickListener(dialogClickListener);
                }
                twoButtonDialog.show();
                break;
            case R.id.notice_dialog:
                if(noticeDialog == null){
                    noticeDialog = new NoticeDialog(mContext).setOnDialogClickListener(dialogClickListener);
                }
                noticeDialog.show();
                break;
            case R.id.select_product_dialog:
                if(selectedProductDialog == null){
                    selectedProductDialog = new SelectedProductDialog(mContext, mView.findViewById(R.id.dialog_ll)).setOnDialogClickListener(dialogClickListener);
                }
                selectedProductDialog.show();
                break;
        }
    }

    OnDialogClickListener dialogClickListener = new OnDialogClickListener() {
        @Override
        public void onDialogClick(Dialog dialog, String clickPosition) {
            if(ClickPosition.CANCEL.equals(clickPosition)){
                dialog.dismiss();
            }else if(ClickPosition.CENTER.equals(clickPosition)){
                dialog.dismiss();
            }else if(ClickPosition.CLOSE.equals(clickPosition)){
                dialog.dismiss();
            }else if(ClickPosition.SUBMIT.equals(clickPosition)){
                dialog.dismiss();
            }
        }
    };
}
